import { Component, EditBox, instantiate, Prefab, _decorator,Node } from "cc";
import { IChatInfo } from "../../../entitys/EntityConst";
import { SNWorld2ChatAction } from "../../../ngame/actions/service/SNWorld2ChatAction";
import { IChatController } from "./IChatController";
const { ccclass, property } = _decorator;


@ccclass('IChatsController')
export default class IChatsController extends Component {

    //输入框
    @property({ type:EditBox, displayName:"输入框" })
    eidt:EditBox = null;

    //聊天框
    @property({ type:Node, displayName:"聊天框" })
    chats:Node = null;

    //聊天框
    @property({ type:Prefab, displayName:"聊天" })
    chat:Prefab = null;


    //发送消息
    onMessage(){

        SNWorld2ChatAction.onMessage(this.eidt.string);

    }

    addChat(message:IChatInfo){

        //向聊天室添加聊天内容
        let chat = instantiate(this.chat);
        chat.getComponent(IChatController).chat = message;
        chat.parent = this.chats;
        

    }

}

